package com.gjy.concurrency.queue;

import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-03-09 10:19:56
 */
public class Q2Test {

    @Test
    public void test2() {
        Sets.SetView<Integer> view = Sets.intersection(Sets.newHashSet(1, 2, 3), Sets.newHashSet(3, 4, 5));
        System.out.println("view = " + view);
    }

    @Test
    public void test1() {
        BlockingQueue<DelayedT1> blockingQueue = new DelayQueue<>();

        blockingQueue.add(new DelayedT1());

        System.out.println("blockingQueue = " + blockingQueue);
    }

    @Test
    public void test3() {
        long convert = TimeUnit.SECONDS.convert(1, TimeUnit.MINUTES);
        System.out.println("convert = " + convert);
    }

    private static final class DelayedT1 implements Delayed {

        @Override
        public long getDelay(@NotNull TimeUnit unit) {
            return 3;
        }

        @Override
        public int compareTo(@NotNull Delayed o) {
            return 0;
        }
    }
}
